package com.missmess.opengldemo.ui;

import android.os.Bundle;

import com.missmess.opengldemo.GlBaseActivity;
import com.missmess.opengldemo.util.BufferUtils;

import java.nio.FloatBuffer;

import javax.microedition.khronos.opengles.GL10;

public class DrawPoint extends GlBaseActivity {
    private float[] vertices = new float[] {
            -0.8f , -0.4f * 1.732f , 0.0f ,
            0.8f , -0.4f * 1.732f , 0.0f ,
            0.0f , 0.4f * 1.732f , 0.0f ,
    };
    private FloatBuffer mVertexBuffer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mVertexBuffer = BufferUtils.float2Buffer(vertices);
    }

    @Override
    public void drawScene(GL10 gl) {
        super.drawScene(gl);
        gl.glTranslatef(0, 0, -4);

        gl.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
        gl.glPointSize(16f);

        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);
        gl.glDrawArrays(GL10.GL_POINTS, 0, 3);
        gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    }
}
